var permuteUnique = function(arr) {
    // 终止条件
    let res = []
    let path = []
    let obj = {}
        // arr.sort()
    arr.forEach((item, index) => {
        obj[index] = true
    });

    function genPermutation() {
        // 终止条件
        if (path.length === arr.length) {
            res.push(path.slice())
            return
        }
        let tempArr = {}
        for (let i = 0; i < arr.length; i++) {
            const item = arr[i];
            if (!obj[i]) {
                continue
            }
            if (tempArr[item]) {
                continue
            } else {
                tempArr[item] = true
            }
            path.push(item)
            obj[i] = false
            genPermutation()
            path.pop()
            obj[i] = true
        }
    }
    genPermutation()
    return res
};

console.log(permuteUnique([3, 3, 0, 3]))